<?php

/**
 * Math
 * 
 * @package 
 * @author menTiss
 * @copyright 2007-2008
 * @version 1.0
 * @access public
 **/
class Math {
	private $_scale = 5 ;
	/**
	 * Math::setScale()
	 * 
	 * @param int $scale
	 * @return 
	 **/
	public function setScale($scale) {
		if(!is_int($scale)) return false ;
		$this->_scale = $scale ;
	}
	/**
	 * Math::sum()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	public function sum($left_operand, $right_operand) {
		if($this->notNumber($left_operand, $right_operand)) return false ;
		return bcadd($left_operand,$right_operand, $this->_scale) ;
	}
	/**
	 * Math::mul()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	public function mul($left_operand, $right_operand) {
		if($this->notNumber($left_operand, $right_operand)) return false ;
		return bcmul($left_operand, $right_operand, $this->_scale) ;
	}
	/**
	 * Math::sub()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	public function sub($left_operand, $right_operand) {
		if($this->notNumber($left_operand, $right_operand)) return false ;
		return bcsub($left_operand, $right_operand, $this->_scale) ;
	}
	/**
	 * Math::div()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	public function div($left_operand, $right_operand) {
		if($this->notNumber($left_operand, $right_operand)) return false ;
		return bcdiv($left_operand, $right_operand, $this->_scale) ;
	}
	/**
	 * Math::mod()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	public function mod($left_operand, $right_operand) {
		if($this->notNumber($left_operand, $right_operand)) return false ;
		return bcmod($left_operand, $right_operand, $this->_scale) ;
	}
	/**
	 * Math::notNumber()
	 * 
	 * @param float $left_operand
	 * @param float $right_operand
	 * @return 
	 **/
	private function notNumber($left_operand, $right_operand) {
		if(is_numeric($left_operand) && is_numeric($right_operand)) return true ;
		return false ;
	}
}

?>